package billrestauration.util;
 
import java.io.File;
import java.net.URL;
import java.util.HashMap;
 
public class MimeUtil {
  private HashMap<String, String> mimeproperties;
  public MimeUtil(HashMap<String, String> mimeproperties) {
	  this();
	  this.mimeproperties.putAll(mimeproperties);
  }
public MimeUtil() {
	 
mimeproperties=new HashMap<String, String>();
 
mimeproperties.put("xul", "text/xul");
mimeproperties.put("tsv", "text/tab-separated-values");
mimeproperties.put("xls", "application/vnd.ms-excel");
mimeproperties.put("xlw","application/vnd.ms-excel");
mimeproperties.put("xla","application/vnd.ms-excel");
mimeproperties.put("xlc","application/vnd.ms-excel");
mimeproperties.put("xlm","application/vnd.ms-excel");
mimeproperties.put("xlt","application/vnd.ms-excel");
mimeproperties.put("man","application/x-troff-man");
mimeproperties.put("pnm","image/x-portable-anymap");
mimeproperties.put("ppm","image/x-portable-pixmap");
mimeproperties.put("ppt","application/vnd.ms-powerpoint");
mimeproperties.put("pps","application/vnd.ms-powerpoint");
mimeproperties.put("pot","application/vnd.ms-powerpoint");
mimeproperties.put("map","magnus-internal/imagemap");
mimeproperties.put("txt","text/plain");
mimeproperties.put("csh","application/x-csh");
mimeproperties.put("zip","application/zip");
mimeproperties.put("fvi","video/isivideo");
mimeproperties.put("sxg","application/vnd.sun.xml.writer.global");
mimeproperties.put("ecert","application/x-x509-email-cert");
mimeproperties.put("sxd","application/vnd.sun.xml.draw");
mimeproperties.put("pbm","image/x-portable-bitmap");
mimeproperties.put("jsc","application/x-javascript-config");
mimeproperties.put("dwg","image/vnd");
mimeproperties.put("svf","image/vnd");
mimeproperties.put("sxc","application/vnd.sun.xml.calc");
mimeproperties.put("nc","application/x-netcdf");
mimeproperties.put("cdf","application/x-netcdf");
mimeproperties.put("mocha","application/x-mocha");
mimeproperties.put("moc","application/x-mocha");
mimeproperties.put("jsu","application/x-javascript;charset=UTF-8");
mimeproperties.put("pcd","image/x-photo-cd");
mimeproperties.put("bin","application/octet-stream");
mimeproperties.put("sxi","application/vnd.sun.xml.impress");
mimeproperties.put("htm","text/html");
mimeproperties.put("html","text/html");
mimeproperties.put("me","application/x-troff-me");
mimeproperties.put("tar","application/x-tar");
mimeproperties.put("ico","image/x-icon");
mimeproperties.put("smp","application/studiom");
mimeproperties.put("smf","application/vnd.stardivision.math");
mimeproperties.put("sdf","application/vnd.stardivision.math");
mimeproperties.put("gif","image/gif");
mimeproperties.put("scert","application/x-x509-server-cert");
mimeproperties.put("png","image/png");
mimeproperties.put("wri","application/x-mswrite");
mimeproperties.put("sda","application/vnd.stardivision.draw");
mimeproperties.put("pl","application/x-perl");
mimeproperties.put("talk","text/x-speech");
mimeproperties.put("crd","application/x-mscardfile");
mimeproperties.put("xbm","image/x-xbitmap");
mimeproperties.put("tki","application/x-tkined");
mimeproperties.put("tkined","application/x-tkined");
mimeproperties.put("midi","audio/midi");
mimeproperties.put("mid","audio/midi");
mimeproperties.put("gz","x-gzip");
mimeproperties.put("ucert","application/x-x509-user-cert");
mimeproperties.put("sh","application/x-sh");
mimeproperties.put("sdw","application/vnd.stardivision.writer");
mimeproperties.put("t","application/x-troff");
mimeproperties.put("tr","application/x-troff");
mimeproperties.put("roff","application/x-troff");
mimeproperties.put("avi","video/msvideo");
mimeproperties.put("xml","text/xml");
mimeproperties.put("doc","application/msword");
mimeproperties.put("dot","application/msword");
mimeproperties.put("wiz","application/msword");
mimeproperties.put("rtf","application/msword");
mimeproperties.put("pgm","image/x-portable-graymap");
mimeproperties.put("sds","application/vnd.stardivision.chart");
mimeproperties.put("ra","audio/x-pn-realaudio");
mimeproperties.put("ram","audio/x-pn-realaudio");
mimeproperties.put("z","x-compress");
mimeproperties.put("xpm","image/x-xpixmap");
mimeproperties.put("asp","application/x-asap");
mimeproperties.put("wrl","x-world/x-vrml");
mimeproperties.put("bmp","image/bmp");
mimeproperties.put("mdb","application/x-msaccess");
mimeproperties.put("etc","application/x-earthtime");
mimeproperties.put("enc","application/pre-encrypted");
mimeproperties.put("class","application/java-vm");
mimeproperties.put("js","application/x-javascript");
mimeproperties.put("ser","application/java-serialized-object");
mimeproperties.put("shar","application/x-shar");
mimeproperties.put("tbp","application/x-timbuktu");
mimeproperties.put("slc","application/x-salsa");
mimeproperties.put("wav","audio/x-wav");
mimeproperties.put("tbt","application/timbuktu");
mimeproperties.put("mpp","application/vnd.ms-project");
mimeproperties.put("ins","application/x-NET-Install");
mimeproperties.put("wv","video/wavelet");
mimeproperties.put("es","audio/echospeech");
mimeproperties.put("esl","audio/echospeech");
mimeproperties.put("lam","audio/x-liveaudio");
mimeproperties.put("pdf","application/pdf");
mimeproperties.put("css","text/css");
mimeproperties.put("fm","application/x-maker");
mimeproperties.put("spr","application/x-sprite");
mimeproperties.put("sprite","application/x-sprite");
mimeproperties.put("ckl","application/x-fortezza-ckl");
mimeproperties.put("dwf","drawing/x-dwf");
mimeproperties.put("ice","x-conference/x-cooltalk");
mimeproperties.put("hlp","application/winhlp");
mimeproperties.put("rtx","text/richtext");
mimeproperties.put("mny","application/x-msmoney");
mimeproperties.put("xwd","image/x-xwindowdump");
mimeproperties.put("cpio","application/x-cpio");
mimeproperties.put("crl","application/x-pkcs7-crl");
mimeproperties.put("jnlp","application/x-java-jnlp-file");
mimeproperties.put("aif","audio/x-aiff");
mimeproperties.put("aiff","audio/x-aiff");
mimeproperties.put("aifc","audio/x-aiff");
mimeproperties.put("shtml","magnus-internal/parsed-html");
mimeproperties.put("etx","text/x-setext");
mimeproperties.put("dvi","application/x-dvi");
mimeproperties.put("m13","application/x-msmediaview");
mimeproperties.put("m14","application/x-msmediaview");
mimeproperties.put("ras","image/x-cmu-raster");
mimeproperties.put("hdf","application/x-hdf");
mimeproperties.put("sti","application/vnd.sun.xml.impress.template");
mimeproperties.put("viv","video/vivo");
mimeproperties.put("vivo","video/vivo");
mimeproperties.put("scd","application/x-msschedule");
mimeproperties.put("mbd","application/mbedlet");
mimeproperties.put("std","application/vnd.sun.xml.draw.template");
mimeproperties.put("tiff","image/tiff");
mimeproperties.put("tif","image/tiff");
mimeproperties.put("svr","x-world/x-svr");
mimeproperties.put("tex","application/x-tex");
mimeproperties.put("jar","application/java-archive");
mimeproperties.put("ifs","image/ifs");
mimeproperties.put("ai","application/postscript");
mimeproperties.put("eps","application/postscript");
mimeproperties.put("ps","application/postscript");
mimeproperties.put("latex","application/x-latex");
mimeproperties.put("sdp","application/vnd.stardivision.impress-packed");
mimeproperties.put("evy","application/x-envoy");
mimeproperties.put("hqx","application/mac-binhex40");
mimeproperties.put("lcc","application/fastman");
mimeproperties.put("sgl","application/vnd.stardivision.writer-global");
mimeproperties.put("ms","application/x-troff-ms");
mimeproperties.put("tcl","application/x-tcl");
mimeproperties.put("stw","application/vnd.sun.xml.writer.template");
mimeproperties.put("aim","application/x-aim");
mimeproperties.put("wmf","application/x-msmetafile");
mimeproperties.put("src","application/x-wais-source");
mimeproperties.put("jpeg","image/jpeg");
mimeproperties.put("jpg","image/jpeg");
mimeproperties.put("jpe","image/jpeg");
mimeproperties.put("jfif","image/jpeg");
mimeproperties.put("pjpeg","image/jpeg");
mimeproperties.put("pjp","image/jpeg");
mimeproperties.put("movie","video/x-sgi-movie");
mimeproperties.put("cacert","application/x-x509-ca-cert");
mimeproperties.put("dtd","application/xml-dtd");
mimeproperties.put("sit","application/x-stuffit");
mimeproperties.put("sdm","application/vnd.stardivision.mail");
mimeproperties.put("stc","application/vnd.sun.xml.calc.template");
mimeproperties.put("trm","application/x-msterminal");
mimeproperties.put("gtar","application/x-gtar");
mimeproperties.put("pub","application/x-mspublisher");
mimeproperties.put("pae","audio/x-epac");
mimeproperties.put("qt","video/quicktime");
mimeproperties.put("mov","video/quicktime");
mimeproperties.put("moov","video/quicktime");
mimeproperties.put("uu","x-uuencode");
mimeproperties.put("uue","x-uuencode");
mimeproperties.put("proxy","application/x-ns-proxy-autoconfig");
mimeproperties.put("texinfo","application/x-texinfo");
mimeproperties.put("texi","application/x-texinfo");
mimeproperties.put("fif","image/fif");
mimeproperties.put("mpeg","video/mpeg");
mimeproperties.put("mpg","video/mpeg");
mimeproperties.put("mpe","video/mpeg");
mimeproperties.put("mpv","video/mpeg");
mimeproperties.put("vbs","video/mpeg");
mimeproperties.put("mpegv","video/mpeg");
mimeproperties.put("mif","application/x-mif");
mimeproperties.put("mi","application/x-mif");
mimeproperties.put("cgi","magnus-internal/cgi");
mimeproperties.put("exe","magnus-internal/cgi");
mimeproperties.put("bat","magnus-internal/cgi");
mimeproperties.put("ief","image/ief");
mimeproperties.put("vrt","x-world/x-vrt");
mimeproperties.put("wi","image/wavelet");
mimeproperties.put("mpv2","video/x-mpeg2");
mimeproperties.put("mp2v","video/x-mpeg2");
mimeproperties.put("sxw","application/vnd.sun.xml.writer");
mimeproperties.put("rgb","image/x-rgb");
mimeproperties.put("pac","audio/x-pac");
mimeproperties.put("sdc","application/vnd.stardivision.calc");
mimeproperties.put("sxm","application/vnd.sun.xml.math");
mimeproperties.put("clp","application/x-msclip");
mimeproperties.put("oda","application/oda");
mimeproperties.put("au","audio/basic");
mimeproperties.put("snd","audio/basic");
mimeproperties.put("sdd","application/vnd.stardivision.impress");
mimeproperties.put("asd","application/astound");
mimeproperties.put("asn","application/astound");


}
public String getMimeType(String extension){
	try{
extension=extension.trim().toLowerCase();
if(extension.indexOf('.')>=0) 
	
	extension=extension.substring(extension.lastIndexOf('.')+1);

if(mimeproperties.containsKey(extension))
	return mimeproperties.get(extension);

return "application/octet-stream";
	}catch(Exception e){
		e.printStackTrace();
		return "application/octet-stream";
	}
 


}
public String getMimeType(File file){
 return getMimeType(file.getName());


}
public String getMimeType(URL url){
	 return getMimeType(url.getFile());
	}

}
